<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>table</title>
	<link rel="stylesheet" href="../css/market.css">
	<style type="text/css">
		.freeze-box {
			min-height: 150px;
			position: relative;
		}
		.freeze-box .freeze-table {
			z-index: 2;
			background: white;
			left: 0;
			top: 0;
		}
		.market-table-box {
			max-height: 200px;
			overflow-y: scroll;
		}
		.freeze-box .market-table {
			z-index: 1;
		}
		.text {
			width: 200px;
			height: auto;  
		    word-wrap:break-word;  
		    word-break:break-all;  
		    overflow: hidden;
		}
	</style>
</head>
<body>
	<div href="" class="text">1111111111111111111111111111111111111111111111111</div>
	<div class="freeze-box" style="margin-top: 300px;">
		<table class="freeze-table market-table" id="freezeTable">
			<colgroup>
				<col width="100"></col>
				<col width="180">
				<col>
			</colgroup>
			<thead></thead>
			<tbody></tbody>
		</table>	
		<div class="market-table-box">
			<table class="market-table" id="table">
				<colgroup>
					<col width="100"></col>
					<col width="180">
					<col>
				</colgroup>
				<thead></thead>
				<tbody></tbody>
			</table>
		</div>
	</div>
</body>
</html>
<script type="text/javascript" src="../lib/jquery/dist/jquery.min.js"></script>
<script type="text/javascript">
	$(function() {
		var $table = $('#table')
		var $thead = $table.find('thead')
		var $tbody = $table.find('tbody')
		var freezeStr = ''
		var theadStr = ''
		var tbodyStr = ''
		var data = [
			{ id: 1, name: 'defore', age: 25 },
			{ id: 2, name: 'tom', age: 25 },
			{ id: 3, name: 'james', age: 25 },
			{ id: 4, name: 'zero', age: 25 },
			{ id: 5, name: 'hh', age: 25 },
			{ id: 1, name: '666', age: 25 },
			{ id: 2, name: 'tt', age: 25 },
			{ id: 3, name: 'area', age: 25 },
			{ id: 4, name: '11', age: 25 },
			{ id: 5, name: '2323123', age: 25 },
			{ id: 1, name: 'defore', age: 25 },
			{ id: 2, name: 'tom', age: 25 },
			{ id: 3, name: 'james', age: 25 },
			{ id: 4, name: 'zero', age: 25 },
			{ id: 5, name: 'hh', age: 25 },
			{ id: 1, name: '666', age: 25 },
			{ id: 2, name: 'tt', age: 25 },
			{ id: 3, name: 'area', age: 25 },
			{ id: 4, name: '11', age: 25 },
			{ id: 5, name: '2323123', age: 25 }
		]
		theadStr += '<tr><th colspan="3">头部</th></tr>'
		theadStr += '<tr><th>id</th><td>用户名</td><td>age</td></tr>'
		freezeStr += '<tr class="freeze"><th colspan="4">头部</th></tr>'
		freezeStr += '<tr class="freeze"><th>id</th><td>用户名</td><td>age</td><td style="width: 17px;"></td></tr>'

		data.forEach(function (item) {
			tbodyStr += '<tr>';
			tbodyStr += '<td>'+ item.id +'</td>';
			tbodyStr += '<td>'+ item.name +'</td>';
			tbodyStr += '<td>'+ item.age +'</td>';
			tbodyStr += '</tr>';
		})
		$('#freezeTable tbody').append(freezeStr)
		// $tbody.append(theadStr)
		$tbody.append(tbodyStr)
	})
</script>